Platform Explorer / Nuxeo Platform 2023.15

Component org.nuxeo.ecm.core.api.versioning.VersioningService

Documentation

The versioning service hold the versioning policy used to define what happens to a document's version when it is created, saved, checked in, checked out or restored, and what version increment options (none, minor, major) are made available to the user.

@Since 5.4

Resolution Order

98
The resolution order represents the order in which this component has been resolved by the Nuxeo Runtime framework.
You can influence this order by adding "require" tags in your component declaration, to make sure it is resolved after another component.

Start Order

802
The start order represents the order in which this component has been started by the Nuxeo Runtime framework.
This number is interesting to tweak if your Java component interacts with other components, and needs to be started before or after another one.
It can be changed by implementing the method "Component#getApplicationStartedOrder()" on your Java component: components are sorted according to this reference value, in increasing order.
The default value is 1000, and the repository initialization uses number 100. Negative values can also be used.

Implementation

Class: org.nuxeo.ecm.core.versioning.VersioningComponent

Services

Extension Points

XML Source

<?xml version="1.0"?>
<component name="org.nuxeo.ecm.core.api.versioning.VersioningService">
  <service>
    <provide interface="org.nuxeo.ecm.core.api.versioning.VersioningService" />
  </service>

  <implementation class="org.nuxeo.ecm.core.versioning.VersioningComponent" />

  <documentation>
    The versioning service hold the versioning policy used to define what
    happens to a document's version when it is created, saved, checked in,
    checked out or restored, and what version increment options (none, minor,
    major) are made available to the user.

    @Since 5.4
  </documentation>

  <extension-point name="versioningService">
    <documentation>
      Extension point defining the implementation of the versioning policy.
      Example:

      <code>
        <service class="some-class" />
      </code>

      The provided class must implement
      org.nuxeo.ecm.core.api.versioning.VersioningService

      The default implementation is
      org.nuxeo.ecm.core.versioning.StandardVersioningService
    </documentation>

    <object class="org.nuxeo.ecm.core.versioning.VersioningServiceDescriptor" />

  </extension-point>

  <extension-point name="policies">

    <documentation>
      Extension point defining versioning policies for documents.
      Contributions to this extension point are available for VersioningService
      implementing ExtendableVersioningService interface.

      Example:
      <code>
        <policy id="no-versioning-for-system-before-update" beforeUpdate="true" increment="NONE" order="1">
          <filter-id>system-document</filter-id>
        </policy>
        <policy id="no-versioning-for-system-after-update" increment="NONE" order="1">
          <filter-id>system-document</filter-id>
        </policy>
        <policy id="versioning-with-initial-version" increment="MINOR" order="2">
          <initialState major="1" minor="0" />
        </policy>
      </code>

      The beforeUpdate attribute enables, if set to true,
      to apply versioning before the actual update of the document.
      The default value for this attribute is false.

      The increment attribute defines which version number
      (minor or major) have to be incremented.
      The available options for this attribute are :
        - NONE
        - MINOR
        - MAJOR

      The order attribute defines in which order the policies
      should be taken into account. They are taken in ascending order.

      Initial state is the initial version number of the document.
      Default is 0.0.

      Each policy contains one or multiple filters
      defining under which conditions the document should be versioned
      (Note that filters for a policy are OR-ed).

      @since 9.1
    </documentation>

    <object class="org.nuxeo.ecm.core.versioning.VersioningPolicyDescriptor" />

  </extension-point>

  <extension-point name="filters">

    <documentation>
      Extension point defining filters which can be used
      by one or multiple versioning policies.
      Contributions to this extension point are available for VersioningService
      implementing ExtendableVersioningService interface.

      Example :
      <code>

        <filter id="class-filter" class="foo.bar.CustomVersioningFilter"/>

        <filter id="collaborative-filter-on-files">
          <type>File</type>
          <condition>#{previousDocument.dc.lastContributor != currentDocument.dc.lastContributor}</condition>
        </filter>

        <filter id="empty">
          <type></type>
          <facet></facet>
          <schema></schema>
          <condition></condition>
        </filter>
      </code>

      A custom filter can be defined with the class attribute
      if a java class should be used for the filter.
      Otherwise, a StandardVersioningFilter will be used
      with the following elements available:

       - The type element defines which document type will be versioned.

       - The facet/schema element defines that the document
         will be versioned if it contains the facet/schema.

       - The condition element enables creating
         a custom condition with an EL expression.

      Note that elements for a filter are AND-ed.

      @since 9.1
    </documentation>

    <object class="org.nuxeo.ecm.core.versioning.VersioningFilterDescriptor" />

  </extension-point>

  <extension-point name="restrictions">
    <documentation>
      Extension point defining restrictions of versioning option by document type. Contributions to this XP are
      available for VersioningService implementing ExtendableVersioningService interface.

      Example:

      <code>
        <restriction type="File">
          <options lifeCycleState="project">
            <option>NONE</option>
            <option default="true">MINOR</option>
          </options>
          <options lifeCycleState="approved" />
        </restriction>

        <restriction type="*">
          <options lifeCycleState="*">
            <option default="true">NONE</option>
            <option>MINOR</option>
            <option>MAJOR</option>
          </options>
          <options lifeCycleState="approved">
            <option default="true">NONE</option>
            <option>MINOR</option>
          </options>
        </restriction>
      </code>

      "type" attribute is available for restriction tag and should be the name of a document type.

      The restriction with type "*" will be used for all the document types if no specific restriction is contributed.

      Options tag contains the different increment option available when saving a document. If the default attribute
      isn't set, the first tag will be used as default. Options tag should always have the lifeCycleState attribute.
      The life cycle state name "*" can be used to match any state: it'll be used by default if no other option with
      a matching state exists.

      Following option gives no increment saving option when the current life cycle of the document is approved.
      <code>
        <options lifeCycleState="approved" />
      </code>

      Following options removes major increment option and set the minor increment option as default choice when the
      current life cycle of the document is projet.
      <code>
        <options lifeCycleState="project">
          <none />
          <minor default="true" />
        </options>
      </code>

      If no restriction is specified, the restriction with "*" is used. If there is no default restriction, we fall
      back on the service implementation (ie: none, minor and major options are available).

      @since 9.1
    </documentation>

    <object class="org.nuxeo.ecm.core.versioning.VersioningRestrictionDescriptor" />

  </extension-point>

</component>